home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
ab20
/
unarced
/
utilities
/
shells
/
sksh
/
scr_source
/
path.s
< prev
next >
Wrap
Text File
|
1995-03-17
|
2KB
|
68 lines
#!c:sksh
#*************************************************************************
# The following function implements the SKsh path command
#*************************************************************************
local _comp _deltap _o_add _o_cd _o_man _o_path _dir _var
_o_add=''; _o_cd=''; _o_man=''; _o_path='T'
_deltap="$PATH"; _var='PATH'
# --- parse the command line switches ------------------------------------
while [ $(expr substr "$1" 1 1) = '-' ]
do
case "$1" in
-add ) _o_add='T'; shift
;;
-cd ) _o_cd='T'; _o_path=''; _deltap="$CDPATH"; _var='CDPATH'
shift
;;
-path) shift;
;;
-man ) _o_man='T'; _o_path=''; _deltap="$MANPATH"; _var='MANPATH'
shift
;;
* ) echo 'Usage:' $(basename $0) \
'[ -cd | -path | -man ] [ -add ] dir1,dir2,...'
shift
return 1
;;
esac
done
# --- if no directories were listed, just echo the right path ------------
[ "$#" -eq 0 ] && echo "$_deltap" && return
# --- if the path is to be reset, use the right initial value ------------
if [ -z "$_o_add" ]
then
_deltap=''
[ -n "$_o_path" ] && _deltap='skshbin:,skshscr:,.,c:'
[ -n "$_o_man" ] && _deltap='MAN:,MAN:SKsh'
fi
# --- add the compontents the user gave us to the path -------------------
for _comp in $* do # for each argument, do
while [ -n "$_comp" ]
do
_dir = $(car "$_comp" ',') # first component of path
_comp = $(cdr "$_comp" ',') # rest of path
if [ $( expr index "$_deltap," "$_dir," ) -eq 0 ]
then
if [ -z "$_deltap" ] then _deltap="$_dir"
else _deltap = "$_deltap,$_dir"; fi
fi
done
done
# --- export the path again to the right variable ------------------------
"$_var"="$_deltap" # $_var = PATH, CDPATH, or MANPATH
export -l "$_var"